<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<title>新增审批</title>
		
		<base href="<%=basePath%>">
		<link rel="stylesheet" href="css/bootstrap.css">
		<link rel="stylesheet" href="css/vivo.css">
		<link rel="stylesheet" href="css/cmxform.css">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="stylesheet" href="js/grid/bsgrid.all.min.css" />
		<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	
		
		<script src="js/jquery-1.11.1.js"></script>
		<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
		<script src="js/select2/select2.min.js"></script>
		<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script> 
		<script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
		<script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
		<script type="text/javascript" src="js/sharefunction.js"></script>
		<script language="javascript" type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>

		<script type="text/javascript">
			
			//选择人员
			var i;
			var optVal="0";
			function doSearch(val){
				optVal = val;
				i = layer.open({
					type : 2,
					title : '人员选择',
					shadeClose : false,
					shade : 0.1,
					maxmin : true, //开启最大化最小化按钮
					area : [ '70%', '80%' ],
					content : 'admin/org/user/list2'
				});
			}
			
			function saveDocument() {
				var id = $("#id").val();
				var userName = $("#userName").val();
				var approvalUserName = $("#approvalUserName").val();
				var type = $("#type").val();
				var userId = $("#userId").val();
				var approvalUserid = $("#approvalUserid").val();
				if(userId==""){
					alert("请选择被审批人！");
					return false;
				}
				if(approvalUserid==""){
					alert("请选择审批人！");
					return false;
				}
				var url = "admin/org/approval/add";
				jQuery.ajax({
					type : "post",
					async : false,
					url : url,
					dataType : "json",
					data : {
						id : id,
						type : type,
						userName:userName,
						approvalName:approvalUserName,
						approvalUserid : approvalUserid,
						userid : userId
					},
					success : function(data) {
						if (data.success) {
							alert(data.msg);
						} else {
							alert(data.msg);
						}
					}
				});
			}

		</script>
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="post">
			<div style="padding: 20px">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h5 class="panel-title">审批配置</h5>
					</div>
					<div class="panel-body">
						<table cellpadding="10" cellspacing="5" class="mytable">
							
							<tr>
			                    <td width="90">
			                        	被审批人
			                    </td>
			                    <td>
			                    	<input type="text" name="userName" id="userName" readonly >
			                    	<input type="hidden" name="userId" id="userId" value=""  >
			                    	<span><span>&nbsp;<a id="menuBtn" onclick="doSearch('0') " style='color: #5a98de;cursor: pointer;'>选择</a>
			                    </td>
			                </tr>
							<tr>
								<td>审批类型</td>
								<td>
									<select id="type" style="width: 90px;">
										<option value="0">部门</option>
										<option value="1">个人</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>审批人</td>
								<td>
									<input name="approvalUserName" id="approvalUserName" readonly/>
									<input type="hidden" name="approvalUserid" id="approvalUserid" value=""  >
			                    	<span><span>&nbsp;<a id="menuBtn" onclick="doSearch('1') " style='color: #5a98de;cursor: pointer;'>选择</a>
								</td>
							</tr>
						</table>
					</div>
				</div>
				<div style="width: 100%; text-align: center; padding-top: 20px">
					<button class="btn btn-primary radius primary-vdd" onclick="saveDocument()">保 存</button>
					<a class="btn btn-default radius" onClick="closeLayer();"> 取 消 </a>
					<br />
					<br />
				</div>
			</div>
	
			<div style="display:none">
				<input id="id" name="id" type="hidden" value="" />
			</div>
		</form>
	</body>
</html>

